<fieldset>
    <legend>条件搜索</legend>
    <form action="{:request()->url()}" autocomplete="off" class="layui-form layui-form-pane form-search" method="get"
          onsubmit="return false">
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">ID</label>
            <label class="layui-input-inline">
                <input class="layui-input" name="id" placeholder="请输入ID" value="{:input('id')}">
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">对接日期</label>
            <div class="layui-input-inline">
                <input class="layui-input" data-date-range name="time_docking" placeholder="请选择对接日期"
                       value="{:input('time_docking','')}">
            </div>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">完成日期</label>
            <div class="layui-input-inline">
                <input class="layui-input" data-date-range name="time_complete" placeholder="请选择完成日期"
                       value="{:input('time_complete','')}">
            </div>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">所在区域</label>
            <div class="layui-input-inline" style="display: flex !important;width: 380px">
                <label class="layui-col-xs6"><select class="layui-select" lay-filter="query_province"
                                                     name="query_province"></select></label>
                <label class="layui-col-xs6"><select class="layui-select" lay-filter="query_city"
                                                     name="query_city"></select></label>
                <label class="layui-col-xs6"><select class="layui-select" lay-filter="query_area"
                                                     name="query_area"></select></label>
            </div>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">司机</label>
            <label class="layui-input-inline">
                <input class="layui-input" name="username" placeholder="请输入司机" value="{:input('username')}">
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">调度员</label>
            <label class="layui-input-inline">
                <input class="layui-input" name="uuid_docking_name" placeholder="请输入调度员" value="{:input('uuid_docking_name')}">
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">城市负责人</label>
            <label class="layui-input-inline">
                <input class="layui-input" name="uuid_city_name" placeholder="请输入城市负责人" value="{:input('uuid_city_name')}">
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">车牌</label>
            <label class="layui-input-inline">
                <input class="layui-input" name="plate_number" placeholder="请输入车牌"
                       value="{:input('plate_number')}">
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">电话</label>
            <label class="layui-input-inline">
                <input class="layui-input" name="phone" placeholder="请输入电话" value="{:input('phone')}">
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">喷漆完成</label>
            <div class="layui-input-inline">
                <select class="layui-select" name="paint_status">
                    <option value=''>-- 全部 --</option>
                    {foreach ['-1'=> '其他', 0 => '否', 1 => '是'] as $k=>$v}
                    {if $k.'' eq input('paint_status')}
                    <option selected value="{$k}">{$v}</option>
                    {else}
                    <option value="{$k}">{$v}</option>
                    {/if}{/foreach}
                </select>

            </div>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">尾部喷漆</label>
            <div class="layui-input-inline">
                <select class="layui-select" name="end_paint_status">
                    <option value=''>-- 全部 --</option>
                    {foreach ['否', '是'] as $k=>$v}
                    {if $k.'' eq input('end_paint_status')}
                    <option selected value="{$k}">{$v}</option>
                    {else}
                    <option value="{$k}">{$v}</option>
                    {/if}{/foreach}
                </select>

            </div>
        </div>

        <div class="layui-form-item layui-inline">
            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
            <!--{if auth("indexExport")}-->
            <button class="layui-btn layui-btn-primary"
                    data-form-export="{:url('indexExport')}?time_docking={:input('time_docking')}&time_complete={:input('time_complete')}&query_province={:input('query_province')}&query_city={:input('query_city')}&query_area={:input('query_area')}&plate_number={:input('plate_number')}&phone={:input('phone')}&paint_status={:input('paint_status')}&fail_status={:input('fail_status')}&username={:input('username')}&uuid_city_name={:input('uuid_city_name')}"
                    type="button">
                <i class="layui-icon layui-icon-export"></i> 导 出
            </button>
            <!--{/if}-->
        </div>
    </form>

</fieldset>

<script>
    window.form.render();
    require(['excel'], function (excel) {
        excel.bind(function (data) {
            var items = [];
            items.push(['ID', '对接日期', '完成日期', '城市', '归属城市', '司机', '车牌', '电话', '车型', '喷漆完成', '车身颜色', '首次邀约情况', '首次邀约日期', '最近邀约情况', '最近邀约日期', '喷漆师傅', '是否有覆盖', '广告覆盖是否收费', '覆盖几面', '调度员', '城市负责人']);
            data.forEach(function (item) {
                items.push([
                    {v: item.id, t: 'n'},
                    item.time_docking,
                    item.time_complete,
                    item.province + item.city + item.area,
                    item.city_owner || '',
                    item.username || '',
                    item.plate_number || '',
                    item.phone || '',
                    item.car_vehicle_type || '',
                    item.paint_status_text || '',
                    item.car_color || '',
                    item.invite_remark || '',
                    item.time_invite || '',
                    item.invite_remarks || '',
                    item.time_invites || '',
                    item.painter || '',
                    item.has_cover_text || '',
                    item.ad_cover_fee_text || '',
                    item.cover_num || '',
                    item.name_docking || '',
                    item.name_city || '',
                ]);
            });
            return items;
        }, '信息采集数据');
    });


    /*! 表单初始化 */
    require(['pcasunzips'], function () {
        (function (prov, city, area, refresh) {
            new PCAS("query_province", "query_city", "query_area", prov, city, area);
            refresh(), form.on('select(query_province)', refresh), form.on('select(query_city)', refresh), form.on('select(query_area)', refresh);
        })("{:input('query_province','')}", "{:input('query_city','')}", "{:input('query_area','')}", function (data) {
            (data && $(data.elem).trigger('change')), setTimeout(function () {
                layui.form.render();
            }, 100);
        });
    });
</script>
